﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LunwenYun.Infrastructure.Entities.Repository;

namespace LunwenYun.Infrastructure.Entities.Entity
{
    public class Purpose : IAccessible<T_Purpose, Purpose>, ILogicEntity<T_Purpose, Purpose>
    {
        #region
        public int Id { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 投稿意向
        /// </summary>
        public string IndType { get; set; }
        /// <summary>
        /// 稿件标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 稿件标题_EN
        /// </summary>
        public string Title_EN { get; set; }
        /// <summary>
        /// 摘要
        /// </summary>
        public string Abstract { get; set; }
        /// <summary>
        /// 摘要_EN
        /// </summary>
        public string Abstract_EN { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime ExpireTime { get; set; }
        /// <summary>
        /// 费用范围
        /// </summary>
        public string PriceRange { get; set; }
        public bool AcceptShortMessage { get; set; }
        /// <summary>
        /// 联系方式
        /// </summary>
        public string ContactInfo { get; set; }
        public bool IsDelete { get; set; }
        #endregion

        protected override void Covariant(T_Purpose model)
        {
            if (model != null)
            {
                this.Abstract = model.Abstract;
                this.Abstract_EN = model.Abstract_EN;
                this.AcceptShortMessage = model.AcceptShortMessage;
                this.ContactInfo = model.ContactInfo;
                this.CreateTime = model.CreateTime;
                this.ExpireTime = model.ExpireTime;
                this.Id = model.Id;
                this.IndType = model.IndType;
                this.IsDelete = model.IsDelete;
                this.PriceRange = model.PriceRange;
                this.Title = model.Title;
                this.Title_EN = model.Title_EN;
                this.UserName = model.UserName;
            }
        }

        protected override T_Purpose Inverter(Purpose model)
        {
            if (model != null)
            {
                return new T_Purpose() { 
                    Abstract=model.Abstract,
                    Abstract_EN=model.Abstract_EN,
                    AcceptShortMessage=model.AcceptShortMessage,
                    ContactInfo=model.ContactInfo,
                    CreateTime=model.CreateTime,
                    ExpireTime=model.ExpireTime,
                    Id=model.Id,
                    IndType=model.IndType,
                    IsDelete=model.IsDelete,
                    PriceRange=model.PriceRange,
                    Title=model.Title,
                    Title_EN=model.Title_EN,
                    UserName=model.UserName
                };
            }
            return null;
        }

        public Purpose Set(T_Purpose dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
